package com.example.android.listeners;

import java.util.ArrayList;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;

import com.example.android.gestures.AccRecord;

public class AccelerometerEventListener implements SensorEventListener
{		
	ArrayList<AccRecord> accRecording;
	
	public AccelerometerEventListener(ArrayList<AccRecord> accRecording)
	{
		super();
		this.accRecording = accRecording;
	}

	@Override
	public void onSensorChanged(SensorEvent event)
	{
		if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
			return;

		float SensorX;
		float SensorY;
		float SensorZ;
		long SensorTimeStamp;

		SensorX = event.values[0];
		SensorY = event.values[1];
		SensorZ = event.values[2];

		SensorTimeStamp = event.timestamp;
		// mCpuTimeStamp = System.nanoTime();

		AccRecord accRecord = new AccRecord(SensorX, SensorY, SensorZ,
				SensorTimeStamp);
		accRecording.add(accRecord);
	}

	@Override
	public void onAccuracyChanged(Sensor sensor,
			int accuracy)
	{
		// TODO Auto-generated method stub
		
	}
}
